package main

import (
	"fmt"
	"time"

	"github.com/libi/dcron"
	"github.com/libi/dcron/driver/redis"
)

func main() {
	drv, _ := redis.NewDriver(&redis.Conf{
		Host: "127.0.0.1",
		Port: 6379,
	})
	cron1 := dcron.NewDcron("cron1", drv)

	cron1.AddFunc("demo1", "* * * * *", func() {
		fmt.Println("this is cron 1111111")
	})

	cron2 := dcron.NewDcron("cron2", drv)

	cron2.AddFunc("demo2", "* * * * *", func() {
		fmt.Println("this is cron 222222222")
	})
	cron1.Start()
	cron1.Start()
	cron2.Start()

	go func() {
		time.Sleep(3 * time.Minute)
		cron1.Stop()
	}()
	fmt.Println("----------")
	select {}
}
